import request from '@/utils/request'
import { CommonSearch } from '@/config/list'
import { StarTreeNode } from '@/model/common/tree/model'
import { PrivilegeList, PrivilegeBeanData } from '@/model/system/privilege/model'

export function loadPrivilegeTree () {
  return request<StarTreeNode[]>({
    url: '/starPrivilege/loadTree'
  })
}

export function loadDataListByFid (data: CommonSearch) {
  return request<PrivilegeList>({
    url: '/starPrivilege/loadDataListByFid',
    data: data,
    method: 'post'
  })
}

export function deleteData (id: string) {
  return request({
    url: `/starPrivilege/remove?id=${id}`
  })
}

export function loadPrivilegeById (id: string) {
  return request({
    url: `/starPrivilege/loadPrivilegeById?id=${id}`,
    method: 'post'
  })
}

export function saveOrUpdate (data: PrivilegeBeanData) {
  return request<PrivilegeBeanData>({
    url: '/starPrivilege/saveOrUpdate',
    data: data,
    method: 'post'
  })
}

export function getMaxIndex (fid: string) {
  return request({
    url: `/starPrivilege/getMaxIndex?fid=${fid}`,
    method: 'post'
  })
}

export function loadSelectTree () {
  return request<StarTreeNode[]>({
    url: '/starPrivilege/loadSelectTree'
  })
}
